<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    #temprature{
        width:200px;
        height:100px;
        border:1px solid #000;
}
</style>
</head>
<body>
<div id = "temprature">
</div>
<script>
    //1 创建一个异步访问对象
    var xhr = new XMLHttpRequest();
    //2 打开一个链接
    xhr.open('GET','http://10.1.93.126:8082/login.php');
    //3 发送请求
    xhr.send();
    //4 获取服务器中返回的数据
    xhr.onreadystatechange=function(){

    if(xhr.readyState == XMLHttpRequest.DONE){
           //5 数据请求
           console.log(xhr.responseText);
           //6 将温度字符串转换成为整数
           var temper = Number.parseInt(xhr.responseText);
           
           var div = document.querySelector('#temperature');
           if(temper <= 10){
                         //这是蓝色背景
              div.style.backgroundColor = 'blue';
           }else{
                         //显示红色背景
               div.style.backgroundColor = 'red';
          }
     }
} 
</script>
</body>
</html>